package com.yixun.qfbao.exception.enums;



/**
 * 错误代码维护
 * 
 * @author Administrator
 * 
 */
public enum ExceptionCodeEnum {
	// 系统异常 runtime exception
	UNKNOW_EXCEPTON("9999","未知异常","服务器忙"),
	OVAL_ERROR("001","参数验证异常","请检查参数是否输入正确"),
	TERMINAL_CODE_ERROR("002","设备号参数有误","设备号参数有误"),
	
	FILE_NO_EXIST("1000","文件不存在","文件不能为空!"),
	IMG_PATH_ERROR("1001","文件路径错误","文件路径配置错误!"),
	File_SIZE_ERROR("1003", "文件过大", "文件大小不能超过50kb"),
	SAVE_IMG_FAIL("1002","文件保存错误","服务器忙!"),


	
	DATE_FORMAT_ERROR("1001", "时间格式化错误", "系统错误！")

	;

	private ExceptionCodeEnum(String code, String desin, String desout) {
		this.code = code;
		this.desin = desin;
		this.desout = desout;
	}

	private String code;
	private String desin;
	private String desout;

	public String getCode() {
		return code;
	}

	public String getDesin() {
		return desin;
	}

	public String getDesout() {
		return desout;
	}

	public static ExceptionCodeEnum getByCode(String code) {
		if (code != null && !"".equals(code.trim())) {
			for (ExceptionCodeEnum mnum : values()) {
				if (mnum.getCode().equals(code)) {
					return mnum;
				}
			}
		}
		return null;
	}

	public static String getInMsg(String code) {
		if (code != null && !"".equals(code.trim())) {
			for (ExceptionCodeEnum mnum : values()) {
				if (mnum.getCode().equals(code)) {
					return mnum.getDesin();
				}
			}
		}
		return null;
	}

	public static String getOutMsg(String code) {
		if (code != null && !"".equals(code.trim())) {
			for (ExceptionCodeEnum mnum : values()) {
				if (mnum.getCode().equals(code)) {
					return mnum.getDesout();
				}
			}
		}
		return null;
	}
}
